import React , { Component } from 'react';


import { ThemeContext } from './createContext';    //引入

class ThemedButton extends Component {
    constructor(props){
        super(props);
        this.state = {
            obj:{
                a:"1",
                b:"2"
            }
        }
    }
    componentDidMount(){
        const obj2 = {
            c:'4',
            d:'5'
        }
        this.timer = setTimeout(()=>{
            // this.setState({
            //     obj: {
            //         ...this.state.obj,
            //         ...obj2
            //     }
            // })
            this.setState((state,props)=>({
                obj:{
                    ...state.obj,
                    ...obj2
                }
            }))
        },1000)
        // obj: Object.assign(this.state.obj,obj2)
        
    }
    componentWillUnmount(){
        clearTimeout(this.timer)
    }
    static contextType = ThemeContext;
    render() {
        // /*return <Button theme={this.props.theme} />;*/
        // console.log(this.context)
        // const arr1 = [1,2,3,4];
        // const arr2 = [5,6,7,8];
        // const arr = [...arr1,...arr2]
        // console.log(arr)
        // var numbers = [4, 38];
        //
        // console.log(numbers instanceof Array);
        // console.log((...numbers) instanceof Array);
        console.log(this.state.obj)
        return (
            <div>
            11111

           {this.props.theme}
            </div>
        )
    }
}


export default ThemedButton;
